<%-- 管理员教师更新数据处理页面 --%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="org.edu.system.DBConnect"%>
<%@page import="org.edu.system.LogWriter" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		String ids = (String) (session.getAttribute("UserName"));//设置当前管理员id为id
		request.setCharacterEncoding("utf-8");//统一字符编码为UTF-8
		System.out.println(ids);//调试输出ids
		String pw = request.getParameter("pw1");//从上一页面调用pw1
		String sql_select = "UPDATE administrator SET adm_passwd = '" + pw + "' WHERE adm_id = '" + ids + "'";//拼接sql语句
		try {
			Connection con = DBConnect.getCon();
			System.out.println(sql_select);
			PreparedStatement pst = con.prepareStatement(sql_select);
			int rs = pst.executeUpdate();//创建sql连接，定义rs，执行
			System.out.println(pst);
			System.out.println(rs);
			if (rs != 0) {
				LogWriter.LogPrint("["+request.getRemoteAddr()+"] "+ids+" 更新密码成功！");
				out.println("更新成功");
	%>

	<%
		}
		} catch (Exception e) {
			LogWriter.LogPrint("["+request.getRemoteAddr()+"] "+ids+" 更新密码失败！");
			out.println(e);
		}
	%>
	<%
   // 重定向到新地址
   String site = new String("./adm_info.jsp");
   response.setStatus(response.SC_MOVED_TEMPORARILY);
   response.setHeader("Location", site); 
%>
</body>
</html>